package cn.wolfcode.wolf2w.business.controller;

import cn.wolfcode.wolf2w.business.service.ISmsService;
import cn.wolfcode.wolf2w.common.core.domain.R;
import cn.wolfcode.wolf2w.member.api.domain.UserInfo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/sms")
@Api(value = "sms短信操作的控制器接口",description = "sms资源控制器")
public class SmsController {

    @Autowired
    private ISmsService smsService;

    @ApiOperation(value = "发送验证码",notes = "给指定手机号码发送验证码")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号",name = "phone",dataType = "String",required = true),
            @ApiImplicitParam(value = "测试参数",name = "i",dataType = "Integer",required = false,defaultValue = "0")
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功"),
            @ApiResponse(code = 201,message = "创建成功"),
            @ApiResponse(code = 401,message = "没登录"),
            @ApiResponse(code = 403,message = "没权限"),
            @ApiResponse(code = 404,message = "接口找不到"),
            @ApiResponse(code = 500,message = "服务器内部异常，请联系管理员"),
            @ApiResponse(code = 501,message = "接口业务异常")
    })
    @PostMapping("/sendVerifyCode")
    public R<?> sendVerifyCode(String phone,Integer i){
        System.err.println(phone);
        smsService.senVerifyCode(phone);
        return R.ok();
    }



    @ApiIgnore
    @ApiOperation(value = "测试API接口",notes = "用于测试APIModel注解")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "手机号",name = "phone",dataType = "String",required = true),
//            @ApiImplicitParam(value = "测试参数",name = "i",dataType = "Integer",required = false,defaultValue = "0")
//    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功"),
            @ApiResponse(code = 201,message = "创建成功"),
            @ApiResponse(code = 401,message = "没登录"),
            @ApiResponse(code = 403,message = "没权限"),
            @ApiResponse(code = 404,message = "接口找不到"),
            @ApiResponse(code = 500,message = "服务器内部异常，请联系管理员"),
            @ApiResponse(code = 501,message = "接口业务异常")
    })
    @GetMapping("/testApi")
    public R<?> testApi(UserInfo userInfo){
        return R.ok(userInfo);
    }
}
